//
//  CYContectUsOnlineCell.m
//  cyjf
//
//  Created by tauCross on 2017/8/29.
//  Copyright © 2017年 Auto Financing. All rights reserved.
//

#import "CYContectUsOnlineCell.h"



@implementation CYContectUsOnlineCellObject

@end



@interface CYContectUsOnlineCell ()

@property(nonatomic, strong)UILabel *titleLabel;
@property(nonatomic, strong)UILabel *contentLabel;
@property(nonatomic, strong)UIView *bottomLine;

@end


@implementation CYContectUsOnlineCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self)
    {
        self.contentView.backgroundColor = [UIColor whiteColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.titleLabel = [[UILabel alloc] init];
        self.titleLabel.textColor = HEXCOLOR(@"444444");
        self.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightRegular];
        [self.contentView addSubview:self.titleLabel];
        
        self.contentLabel = [[UILabel alloc] init];
        self.contentLabel.textColor = HEXCOLOR(@"444444");
        self.contentLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
        [self.contentView addSubview:self.contentLabel];
        
        self.bottomLine = [UIImageView cy_imageLineWithColor:HEXCOLOR(@"ECECEC")];
        [self.contentView addSubview:self.bottomLine];
    }
    return self;
}

+ (CGFloat)heightForObject:(id)object atIndexPath:(NSIndexPath *)indexPath tableView:(UITableView *)tableView
{
    return 50;
}

- (BOOL)shouldUpdateCellWithObject:(CYContectUsOnlineCellObject *)object
{
    self.titleLabel.text = object.title;
    
    self.contentLabel.text = object.content;
    
    self.bottomLine.hidden = object.isBottom;
    
    [self setNeedsLayout];
    return YES;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    [self.titleLabel sizeToFit];
    self.titleLabel.left = 20;
    self.titleLabel.centerY = self.contentView.height / 2;
    
    [self.contentLabel sizeToFit];
    self.contentLabel.right = self.contentView.width - 20;
    self.contentLabel.centerY = self.contentView.height / 2;
    
    self.bottomLine.height = 1 / SCREEN_SCALE;
    self.bottomLine.width = self.contentView.width - 20;
    self.bottomLine.bottom = self.contentView.height;
    self.bottomLine.right = self.contentView.width;
}

@end
